package trade;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.alibaba.android.vlayout.DelegateAdapter;
import com.alibaba.android.vlayout.LayoutHelper;
import com.alibaba.android.vlayout.layout.SingleLayoutHelper;

import net.ck.hzq.R;

/**
 * by BF00233 on 2018/12/21.
 */
public class TradeMonthAdapter extends DelegateAdapter.Adapter<TradeMonthAdapter.MonthVH> {

    private final Context mContext;
    private final String mMonth;

    public TradeMonthAdapter(Context context, String month) {
        mContext = context;
        mMonth = month;
    }

    @Override
    public LayoutHelper onCreateLayoutHelper() {
        return new SingleLayoutHelper();
    }

    @NonNull
    @Override
    public MonthVH onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        return new MonthVH(LayoutInflater.from(mContext).inflate(R.layout.item_trade_record_month, viewGroup, false));
    }

    @Override
    public void onBindViewHolder(@NonNull MonthVH holder, int i) {
        holder.month.setText(mMonth);
    }

    @Override
    public int getItemCount() {
        return 1;
    }

    class MonthVH extends RecyclerView.ViewHolder {
        private TextView month;

        MonthVH(@NonNull View itemView) {
            super(itemView);
            month = itemView.findViewById(R.id.month);
        }
    }

}
